package com.cssw.fyzb.wap.controller;

import com.cssw.fyzb.base.web.context.UserContext;
import com.cssw.fyzb.base.web.domain.AjaxData;
import com.cssw.fyzb.wap.model.dto.ParseWordDto;
import com.cssw.fyzb.wap.model.dto.ShareLiveDto;
import com.cssw.fyzb.wap.model.dto.ShareVideoDto;
import com.cssw.fyzb.wap.model.vo.ParseWordVo;
import com.cssw.fyzb.wap.model.vo.ShareWordVo;
import com.cssw.fyzb.wap.service.WordCmdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author YangYiQun
 */
@Api(description = "口令相关的接口")
@RestController
@RequestMapping("/word")
public class WordCmdController {

    @Autowired
    private WordCmdService wordCmdService;

    @ApiOperation(value = "分享视频(返回口令)")
    @RequestMapping(value = "/shareVideoWord", method = RequestMethod.POST)
    @ResponseBody
    public AjaxData<ShareWordVo> shareVideoWord(@RequestBody ShareVideoDto dto) {
        return wordCmdService.shareVideoWord(UserContext.getUserId(), dto.getVideoId(), dto.getType());
    }

    @ApiOperation(value = "分享直播(返回口令)")
    @RequestMapping(value = "/shareLiveWord", method = RequestMethod.POST)
    @ResponseBody
    public AjaxData<ShareWordVo> shareLiveWord(@RequestBody ShareLiveDto dto) {
        return wordCmdService.shareLiveWord(UserContext.getUserId(), dto.getLiveId(), dto.getType());
    }

    @ApiOperation(value = "解析口令")
    @RequestMapping(value = "/parseWordCmd", method = RequestMethod.POST)
    @ResponseBody
    public AjaxData<ParseWordVo> parseWordCmd(@RequestBody ParseWordDto dto) {
        return wordCmdService.parseWordCmd(UserContext.getUserId(), dto.getContent());
    }
}
